package com.qunar.flight.myserver;

import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.channels.SelectionKey;
import java.nio.channels.SocketChannel;
import java.nio.charset.Charset;

public class RequestHandler2 implements Handler{
	private SocketChannel sc;

	RequestHandler2(SocketChannel sc) {
		this.sc = sc;
	}
	public void handle() throws IOException {
		System.out.print(getClass());
		ByteBuffer requestBB = ByteBuffer.allocate(1024 * 4);
		sc.read(requestBB);
		System.out.println("�����ַ�Ϊ��" + new String(requestBB.array()).trim());
		sc.write(Charset.forName("GBK").encode("��˺�������"));
		sc.close();		
	}
	
	public void run() {
		try {
			handle();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}
